<?php


/**
* Puree CMS
* http://www.molotsoft.ru
*
* @package Puree_CMS
* @subpackage Elements
* @author Ivan Chistyakov <ivan@molotsoft.ru>
* @version $Id: admin_view_default_field.ctp 723 2010-03-03 12:55:42Z molotsoft@gmail.com $
* @link $HeadURL: http://puree-cms.googlecode.com/svn/trunk/views/elements/automate/admin_view_default_field.ctp $
*/


switch ($field_description['input']['type']) {
	case 'skip': break;
	case 'static': if (isset($this->data[$model][$field_name])) echo '<div class="form_field form_field_static"><label>' . $field_description['input']['label'] . '</label><span class="static">' . $this->data[$model][$field_name] . '</span></div>'; break;
	case 'wysiwyg': {
		$field_description['input']['div'] = 'form_field form_field_textarea';
		$field_description['input']['type'] = 'textarea';
		$field_description['input']['class'] = 'wysiwyg';
		echo $form->input($field_name, $field_description['input']);
		break;
	}
	case 'image': {
		if (isset($field_description['input']['params']['source'])) break; // skip
		$field_description['input']['div'] = 'form_field form_field_file';
		$field_description['input']['type'] = 'file';
		echo $form->input('upload_' . $field_name, $field_description['input']);
		// uploaded
		if (isset($this->data[$model][$field_name . '-uploaded']) && is_array($uploaded = $this->data[$model][$field_name . '-uploaded'])) {
			echo '<div class="form_field form_field_checkbox form_field_uploaded_image">';
			$style = 'height: ' . min($uploaded['height'], 100) . 'px';
			echo $html->link($html->image($uploaded['url_time'], array('class' => 'thumbnail', 'style' => $style)), $uploaded['url_time'], array('class' => 'lightbox'), FALSE, FALSE) . '<br />';
			echo $html->link($uploaded['basename'], $uploaded['url_time']) . '<br />';
			echo __('imagesize_label', TRUE) . ': ' . $uploaded['width'] . 'x' . $uploaded['height'] . '<br />';
			echo __('filesize_label', TRUE) . ': ' . $uploaded['filesize'] . '<br />';
			echo __('filemtime_label', TRUE) . ': ' . date(DATE_FORMAT, $uploaded['filemtime']) . '<br />';
			echo $form->input('delete_' . $field_name, array('label' => __('delete_image_label', TRUE), 'type' => 'checkbox', 'div' => FALSE));
			echo '</div>';
		}
		break;
	}
	case 'file': {
		$field_description['input']['div'] = 'form_field form_field_file';
		$field_description['input']['type'] = 'file';
		echo $form->input('upload_' . $field_name, $field_description['input']);
		// uploaded
		if (isset($this->data[$model][$field_name . '-uploaded']) && is_array($uploaded = $this->data[$model][$field_name . '-uploaded'])) {
			echo '<div class="form_field form_field_checkbox form_field_uploaded_file">';
			echo $html->link($uploaded['basename'], $uploaded['url_time']) . '<br />';
			echo __('filesize_label', TRUE) . ': ' . $uploaded['filesize'] . '<br />';
			echo __('filemtime_label', TRUE) . ': ' . date(DATE_FORMAT, $uploaded['filemtime']) . '<br />';
			echo $form->input('delete_' . $field_name, array('label' => __('delete_file_label', TRUE), 'type' => 'checkbox', 'div' => FALSE));
			echo '</div>';
		}
		break;
	}
	case 'audio': {
		$field_description['input']['div'] = 'form_field form_field_file';
		$field_description['input']['type'] = 'file';
		echo $form->input('upload_' . $field_name, $field_description['input']);
		// uploaded
		if (isset($this->data[$model][$field_name . '-uploaded']) && is_array($uploaded = $this->data[$model][$field_name . '-uploaded'])) {
			echo '<div class="form_field form_field_checkbox form_field_uploaded_audio">';
			echo $this->element('objects' . DS . 'ump3player', array('url' => $uploaded['url_time'])) . '<br />';
			echo $html->link($uploaded['basename'], $uploaded['url_time']) . '<br />';
			echo __('filesize_label', TRUE) . ': ' . $uploaded['filesize'] . '<br />';
			echo __('filemtime_label', TRUE) . ': ' . date(DATE_FORMAT, $uploaded['filemtime']) . '<br />';
			echo $form->input('delete_' . $field_name, array('label' => __('delete_audio_label', TRUE), 'type' => 'checkbox', 'div' => FALSE));
			echo '</div>';
		}
		break;
	}
	case 'video': {
		$field_description['input']['div'] = 'form_field form_field_file';
		$field_description['input']['type'] = 'file';
		echo $form->input('upload_' . $field_name, $field_description['input']);
		// uploaded
		if (isset($this->data[$model][$field_name . '-uploaded']) && is_array($uploaded = $this->data[$model][$field_name . '-uploaded'])) {
			echo '<div class="form_field form_field_checkbox form_field_uploaded_video">';
			echo $this->element('objects' . DS . 'uflvplayer', array('url' => $uploaded['url_time'])) . '<br />';
			echo $html->link($uploaded['basename'], $uploaded['url_time']) . '<br />';
			echo __('filesize_label', TRUE) . ': ' . $uploaded['filesize'] . '<br />';
			echo __('filemtime_label', TRUE) . ': ' . date(DATE_FORMAT, $uploaded['filemtime']) . '<br />';
			echo $form->input('delete_' . $field_name, array('label' => __('delete_video_label', TRUE), 'type' => 'checkbox', 'div' => FALSE));
			echo '</div>';
		}
		break;
	}
	default: {
		$field_description['input']['div'] = 'form_field form_field_' . $field_description['input']['type'];
		echo $form->input($field_name, $field_description['input']);
		break;
	}
}


?>